// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package com.geniusai.aip.auth.utils;

import lombok.extern.slf4j.Slf4j;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import static com.geniusai.aip.auth.constants.LoadConstants.BCRYPT_CONFIG_LONG_ROUND;

/**
 * @author hml14563
 * @date 2021/3/19
 */
@Slf4j
public class BcryptUtil {

    private static BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(BCRYPT_CONFIG_LONG_ROUND);

    public static String bEncryptEncode(String rawPwd) {
        return bCryptPasswordEncoder.encode(rawPwd);
    }

    public static boolean bEncryptMatch(String rawPwd, String dbPwd) {
        return bCryptPasswordEncoder.matches(rawPwd, dbPwd);
    }

}
